package com.example.pharmacy.mapper;

import com.example.pharmacy.model.DrugInfo;
import com.example.pharmacy.model.UserInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: asus
 * Date: 2024-12-21
 * Time: 17:25
 */
@Mapper
public interface DrugInfoMapper {
    @Select("select * from drugs where is_deleted = 0 order by drug_id desc limit #{offset}, #{pageSize}")
    List<DrugInfo> selectDrugInfoByPage(@Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
    @Select("select count(*) from drugs where is_deleted = 0")
    Integer countAll();
    @Select("select * from drugs where is_deleted = 0 && drug_id = #{drugId}")
    DrugInfo selectDrugById(Integer drugId);
    @Select("select * from drugs where is_deleted = 0 and class_id = #{classId} order by drug_id desc")
    List<DrugInfo> selectDrugInfoByCategory(@Param("classId")Integer classId);
    @Select("select count(*) from drugs where is_deleted = 0 and class_id = #{classId}")
    Integer countByCategory(Integer classId);
    Integer addDrug(DrugInfo drugInfo);
    Integer updateDrug(DrugInfo drugInfo);
    @Select("select * from drugs where drug_name like concat('%',#{drugName},'%')")
    List<DrugInfo> selectDrugByName(String drugName);
}
